<!DOCTYPE html>


<html class="x-admin-sm" lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Mobile Shop Account</title>

    <!-- Bootstrap Core CSS -->
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" type="text/css">

    <!-- Custom CSS -->
    <link rel="stylesheet" th:href="@{/css/style.css}">


    <!-- Custom Fonts -->
    <link rel="stylesheet" th:href="@{/font-awesome/css/font-awesome.min.css}" type="text/css">
    <link rel="stylesheet" th:href="@{/fonts/font-slider.css}" type="text/css">

    <!-- jQuery and Modernizr-->
    <script th:src="@{/js/jquery-2.1.1.js}"></script>

    <!-- Core JavaScript Files -->
    <script th:src="@{/js/bootstrap.min.js}"></script>
</head>
<body>
<header style="padding:0">
    <div th:replace="../templates/header::header"></div>
</header>
<center>
    <div class="col-md-6" style="float:none">
        <div class="heading"><h2>New User ? Create An Account.</h2></div>
        <form name="form" id="register" method="post">
            <input type="hidden" th:value="${user1.userId}" id="userId">
            <div class="form-group">
                <input type="text" class="form-control" th:value="${user1.username}" placeholder="User Name :"
                       name="username" id="username"
                       required>
            </div>
            <div class="form-group">
                <input type="email" class="form-control" th:value="${user1.realName}" placeholder="Last Name :"
                       name="lastname" id="lastname"
                       required>
            </div>
            <div class="form-group">
                <input type="tel" class="form-control" th:value="${user1.email}" placeholder="Email Address :"
                       name="email" id="email" required>
            </div>
            <div class="form-group">
                <input type="tel" class="form-control" th:value="${user1.tel}" placeholder="Mobile :" name="phone"
                       id="phone" required>
            </div>
            <div class="form-group">
                <input name="gender" id="gender" type="radio" value="1" th:checked="${user1.sex} == 1?'checked':'false' "> Male
                <input name="gender" id="gender" type="radio" value="0" th:checked="${user1.sex} == 0?'checked':'false' "> Female
            </div>

            <div class="form-group">
                <input type="password" class="form-control" th:value="${user1.password}" placeholder="Password :"
                       name="password" id="password"
                       required>
            </div>
            <!--            <div class="form-group">-->
            <!--                <input type="password" class="form-control" placeholder="Retype Password :" name="repassword"-->
            <!--                       id="repassword" required>-->
            <!--            </div>-->
            <div class="form-group">
                <input name="agree" id="agree" type="checkbox"> I agree to your website.
            </div>
            <button type="button" onclick="update()" class="btn btn-1">Update</button>
            <button type="button" onclick="toAddress()"   class="btn btn-1">添加地址</button>
        </form>
    </div>
</center>
<script th:inline="javascript">
    var basePath = [[${#httpServletRequest.getContextPath()}]];

    var username = $("#userName").val();
    var realName = $("#realName").val();
    var email = $("#email").val();
    var tel = $("#tel").val();
    var sex = $('input:radio:checked').val();
    var password = $("#password").val();


    function update() {
        $.ajax({
            url: basePath + "/user/update",
            type: "post",
            data: {
                "username": username,
                "realName": realName,
                "email": email,
                "tel": tel,
                "sex": sex,
                "password": password
            },
            success: function (obj) {
                if (obj.success) {
                    parent.location.reload();
                } else {
                    alert(obj.mesg);
                }
            },
            dataType: "json"
        })
    }

    function toAddress() {
        var userId = $("#userId").val();
        location.href = basePath + "/user/toAddress?userId="+ userId;
    }
</script>
<!-- 底部结束 -->
<footer>
    <div th:replace="../templates/footer::footer"></div>
</footer>
</body>
</html>